package com.zt.bus.line.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zt.bus.line.model.Vehicle;
import com.zt.bus.line.service.VehicleService;
import com.zt.servlet.ReqBean;
import com.zt.servlet.RequestAttribute;
import com.zt.servlet.Response;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Controller
@RequestMapping(value = "/vehicle")
public class VehicleController {

    @Autowired
    private VehicleService vehicleService;

    /**
     * 查询全部车辆
     *
     * @param reqBean
     * @return
     */
    @RequestMapping(value = "/getAllVehicle")
    @ResponseBody
    public JSONObject getAllBus(final @RequestAttribute(ReqBean.NAME) ReqBean reqBean) {
    	List<Vehicle> ehicleList = vehicleService.getAllVehicle();
    	JSONArray busArray = new JSONArray();
    	for (Vehicle vehicle : ehicleList) {
    		busArray.add(vehicle.toJson(vehicle));
		}
        return Response.response(busArray);
    }

    //TODO 其他功能
}